pp108 : Using the Applicability Service in a Case Model

Using the Applicability Service in a Case Model

While working on a Case model, you may need to take decisions to choose the most applicable sub-set from next set of follow-up activities, based on the context and data available for a Case. In such scenario, it becomes necessary to consider all the possible options and exceptions available for executing a task.

The Applicability Service is a feature that helps you to accomplish tasks easily, while considering all the possible options and exceptions by implementing the required business logic on a Web service. When the Applicability Service feature is selected for the State, it becomes applicable for all the activities within the State. When the activities within the State are executed, based on the work option or exception the Applicability Service is triggered and recommendations are made for the set of  applicable follow-up activities.

Recommendation Types

The  recommendation for a follow-up activity can be of the following types:

  • IsRecommended – Refers to an activity that is recommended to be executed. For example, if a  customer's credit history is poor, an optional activity of verifying the previous banking transactions must be performed.
  • IsNotRecommended – Refers to an activity that is not recommended to be executed. However, the activity can still be manually executed, based on the discretion of the case worker. For example, if a patient's medical condition is clear, further diagnostic checks may not be required.
  • IsWarning – Refers to an activity that may be executed but with a bit of caution as it may have undesirable results. For example, if a patient's medical history mentions an allergy to anesthesia, providing it may risk the patient's condition.

Implementing Applicability Service

The applicability logic can be implemented in the form of a Web service or a Business Process Model (BPM) directly. When Web service is considered, it can be implemented using a Java class, a decision table, or a BPM.  This topic explains the process of implementing the Applicability logic using a Web service generated from a BPM.

Scenario

Consider a Case model that is designed to handle the situation of providing facilities for passengers of the trains that get delayed due to technical reasons. In such a situation, the administration needs to provide facilities to the train passengers based on the current condition in a station. The process is handled by a Case model containing a set of defined activities.

The business logic for this situation is defined based on the parameters - Temperature and Duration of the delay. Typically this information is captured in the Case model in the form of Case Data. Based on this information, the evaluation of applicability for the follow up activities is done.

The following table explains the parameter values and the applicable activities:

 

 

Situation A

Situation B

Situation C

Conditions

Temperature (deg Celcius)

< 5

 

 

 

Delay (minutes)

> 120

90-120

<=90

Activities

OrderSoup

Recommended

NotRecommended

NotRecommended

 

DistributeSoup

Recommended

NotRecommended

NotRecommended

 

ArrangeMobileBeds

Recommended

Warning

Warning

 

HireChairs

NotRecommended

Recommended

Warning


In the above table, Situation A states that if the temperature is less than 5 and the delay is more than 120, the recommended  activities  are OrderSoup, DistributeSoup, and ArrangeMobileBeds. The activity HireChairs is not recommended.

The Case management model below handles the above scenario. It has two states Supply Facilities and Demobilize Facilities. We will define and apply the Applicability Service to the Supply Facilities state, and will implement the Applicability Service using a BPM. In the BPM, the business logic will be implemented using a decision table.

Figure-1: Case Management Model

To build the Applicability Service, do the following:

  1. Create the Case data schema fragment.
  2. Create the decision table schema fragment.
  3. Create the Applicability Service using contract.
  4. Implement the Web service using a BPM.
  5. Create the decision table.
  6. Update the BPM.
  7. Build the Message Map assignments.
  8. Configure the Applicability Service in the Case model.
  9. Execute the Case model.

Step 1: Create the Case data schema fragment

Create an XML Schema document to define the Case data with below instance XML and name it SupplyFacilitiesData.

<ns:CaseData xmlns:ns="http://schemas.applicability.demo/1.0">
<ns:Temperature>string</ns:Temperature>
<ns:ExpectedDelay>string</ns:ExpectedDelay>
</ns:CaseData>

Step 2: Create the decision table schema fragment

Create an XML Schema document to define the facilities data with the following XML instance and name it FacilitiesEvaluationSchema.

<ns:FacilitiesData xmlns:ns="http://schemas.applicability.com/implementation/1.0">
	<ns:CaseData>
		<ns:Temperature>string</ns:Temperature>
		<ns:ExpectedDelay>string</ns:ExpectedDelay>
	</ns:CaseData>
	<ns:Activities>
		<ns:OrderSoup>string</ns:OrderSoup>
		<ns:DistributeSoup>string</ns:DistributeSoup>
		<ns:ArrageMobileBeds>string</ns:ArrageMobileBeds>
		<ns:HireChairs>string</ns:HireChairs>
	</ns:Activities>
</ns:FacilitiesData>

Step 3: Create the Applicability Service using contract

  1. Copy the latest WSDL  contract to the development server. 
    Note: Till BOP 4.3, old WSDL is used for Applicability Service. For backward compatibility reasons, the older WSDL is still supported.
  2. If not already present, you need to create UDDI Service Container.
  3. Create a new Web service using the above contract. 
    1. Right-click a folder and select  New -> Web Service.
    2. In Select the source control, select Import WSDL option, specify Name and Description and click Next.
    3. In the URL input field, provide the URL of the WSDL copied to development server (in Step 1), select the Web service operation as displayed below, and click Finish.

Step 4: Implement the Web service using a BPM

  1. Right-click a folder and select New -> Business process model.
  2. Right-click the editor of the BPM and select Properties.
  3. Select the Contract check box and click  to select the Web service created in Step 3.
  4. Save the BPM.

This generates a skeleton of the BPM with the  defined  contract. You need to implement this logic in the BPM. For this example, we will create a decision table to define our logic.

Step 5: Create the decision table

  1. Right-click a folder and select New -> Rule Group.
  2. Provide a name and description and save the Rule Group.
  3. Right-click the Rule Group and select Add -> Decision Table.
  4. On the left-hand pane of the Decision Table editor, click  to open the FacilitiesData schema fragment that was created in the step 2 above. The schema fragment is available under the FacilitiesEvaluationSchema XML Schema document.
  5. Model the decision table as displayed below:

Note:

  • The assignment values for the activities are different with labels. This is important because these values will be used during evaluation of activities. For example: Value of OrderSoup element in Rule1 is set to isRecommended and the label is defined as Recommended. Refer to Recommendation Types section above for more information.
  • The elements in FacilitiesData schema fragment of FacilitiesEvaluationSchema XML Schema are defined based on the names of the Case activities.

Step 6: Update the BPM

1. Access the BPM created in Step 4 and drag the decision table onto the empty activity. This will replace the empty activity with the decision table activity.
2. Add a new empty activity as displayed below.

Step 7: Build the Message Map assignments

1. Select Evaluate Rules decision table by clicking on the activity and go to the Message Map tab.

2. Set data element as source for the target CaseData element of FacilitiesRulesInput Message as displayed below.

3. Change the assignment operation to Replace With Children with Target NS.

4. Click the  Update Applicability Attributes activity in the activities artifact viewer.

5. Perform the below assignments:

    1. Replace the followups element of EvaluateApplicabilityOutput message with the followups of element of EvaluateApplicabilityInput message. 
    2. Modify the assignment operation to Replace With Select.
    3. Map the activity OrderSoup element value from FacilitiesRulesOutput message to applicability attribute of EvaluateApplicabilityOutput message.
    4. Modify the assignment operation to Replace Content with Select.
    5. Repeat step b for all activity elements, as displayed below.
    6. Click Switch to consolidated view on the toolbar to switch to the consolidated view.
    7. Update all the target assignments in target column with expressions as displayed below.

    8. Save the BPM.

Step 8: Configure the Applicability Service in the Case model

  1. Create a Case model as displayed in Figure 1.
  2. Right-click the model and select Properties to go to its properties view.
  3. Click the Data  tab.
  4. Select the Use XML Schema Fragment (XSD) check box.
  5. Use the look-up button to open the  CaseData schema fragment of the SupplyFacilitiesData XSD created in Step 1.
  6. Right-click the  Supply Facilities state and select Properties to go to its properties view.
  7. Select the type of Applicability Service that you want to configure. 
  8. Click  and select the related Web Service created in Step 3 or Business Processes in step 5 according to the option chosen.
  9. Save the Case model.

Step 9: Execute the Case model

  1. Ensure that you start the Rule repository Service group.
  2. Right-click the project and select Publish to organization.
  3. Attach the Web service interface created in Step 3 to the BPM Engine Service group.
    Note : If you are working in a Non-System organization, ensure that you create a new Business process management Service group in that organization and attach the Web service interface.
  4. Trigger the Case model with the Case data as parameters.
    Note: An easy way to trigger a Case model is to create another BPM and use this Case model in that BPM. Map the input message of Case model to the start event of the BPM.
  5. Go to My Inbox and select the Case model.
  6. Click on the Case instance from the list. Select and double click on the  EvaluateRequirements  activity.

This will internally invoke the Applicability Service defined on the state and evaluate the given inputs.  When evaluated, the output information will be sent to Inbox and the inbox will render the Follow-Ups view with appropriate details as displayed below.

 

Attachments: